package com.small.account.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.basis.oauth.AuUser;
import com.small.account.entity.vo.RemoteGroup;
import com.small.account.entity.vo.RemoteToken;
import com.small.account.entity.vo.RemoteUser;
import com.small.account.service.IAuUserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户
 *
 * @author wangguochao
 */
@RestController
@AllArgsConstructor
@RequestMapping("/flow-user")
public class FlowableController {
    private final IAuUserService iAuUserService;


    public RemoteUser authenticateUser(String username, String password) {

        return null;
    }


    public RemoteToken getToken(String tokenValue) {

        return null;
    }


    public RemoteUser getUser(String userId) {

        return null;
    }

    @GetMapping("findUsersByNameFilter")
    public List<RemoteUser> findUsersByNameFilter(@RequestParam String filter) {
        LambdaQueryWrapper<AuUser> query = Wrappers.lambdaQuery();
        query.like(AuUser::getActualName,filter);
        List<AuUser> list = iAuUserService.list(query);
        ArrayList<RemoteUser> arr = new ArrayList<>();
        for (AuUser user : list) {
            RemoteUser remoteUser = new RemoteUser();
            remoteUser.setDisplayName(user.getActualName());
            remoteUser.setFullName(user.getActualName());
            remoteUser.setFirstName(user.getActualName());
            remoteUser.setLastName(user.getActualName());
            remoteUser.setId(user.getId());
            arr.add(remoteUser);
        }
        return arr;
    }


    public List<RemoteUser> findUsersByGroup(String groupId) {

        return null;
    }

    public RemoteGroup getGroup(String groupId) {

        return new RemoteGroup();
    }


    public List<RemoteGroup> findGroupsByNameFilter(String filter) {

        return null;

    }
}
